<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>仓库统计详情</title>
    <link rel="stylesheet" href="css/table.css">
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/timeformat.js"></script>
</head>
<style>
    #content{
        width: 100%;
        height: auto;
    }

    #table-1 thead, #table-1 tr {
        border-top-width: 1px;
        border-top-style: solid;
        border-top-color: rgb(230, 189, 189);
    }
    #table-1 {
        width: 100%;
        border-bottom-width: 1px;
        border-bottom-style: solid;
        border-bottom-color: rgb(230, 189, 189);
    }

    /* Padding and font style */
    #table-1 td, #table-1 th {
        padding: 5px 10px;
        font-size: 12px;
        font-family: Verdana;
        color: rgb(177, 106, 104);
        text-align: center;
    }

    /* Alternating background colors */
    #table-1 tr:nth-child(even) {
        background: rgb(238, 211, 210);
        text-align: center;
    }
    #table-1 tr:nth-child(odd) {
        background: #FFF
    }
</style>
<body>
<div id="content"></div>
</body>
<script>
    var url = location.search; //获取url中"?"符后的字串 ('?modFlag=business&role=1')
    var theRequest = new Object();
    if ( url.indexOf( "?" ) != -1 ) {
        var str = url.substr(1); //substr()方法返回从参数值开始到结束的字符串；
        var strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
        }
        console.log(theRequest);
        //此时的theRequest就是我们需要的参数；
    }
    $(document).ready(function (){

            $.ajax({
                url: "warehouse/selectwarehouse",
                type: "post",
                data: JSON.stringify({
                    warehouseId:theRequest.warehouseId
                }),
                beforeSend: function (request) {
                    request.setRequestHeader("token", "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwiaWF0IjoxNTMyNDA4ODMzLCJzdWIiOiIxLHd6eSwwIiwiZXhwIjoxNTMyNDE2MDMzfQ.DEpHIrk2X8U4Un_SdDNiqqPPEYHXX6DYfx_prQ3QIZQ");
                },
                contentType: "application/json;",
                success: function (data) {
                    console.log(data);
                    if (data == null || data == "" || data == undefined) {
                        $("#content").html("暂无数据");
                    } else {
                        var content = '<table class="table-1" cellspacing="0" border="0"> <thead>\n' +
                            '\n' +
                            '            <th>材料名称</th>\n' +
                            '            <th>数量</th>\n' +
                            '            <th>类型名称</th>\n' +
                            '            <th>项目名称</th>\n' +
                            '            <th>操作</th>\n' +
                            '        </thead>\n' +
                            '<tbody>';
                        var list = data.data;
                        for (var i = 0; i < list.length;i++) {
                            var obj = list[i];
                            var state = obj.state;
                            if(state == 1){
                                state = "入库";
                            }else{
                                state = "出库";
                            }
                            content += '<tr>' +
                                '<td>' + obj.materialName + '</td>' +
                                '<td>' + obj.materialNumber + '</td>' +
                                '<td>' + obj.materialTypeName + '</td>' +
                                '<td>' + obj.projectName + '</td>' +
                                '<td>' +state + '</td>' +
                                '<tr/>' +
                                '</tbody>';
                        }
                        content +='</table>';
                        console.log(content);
                        $("#content").html(content);
                    }

                }
            });

       });

</script>
</html>